// 导入
import Vue from "vue";
import VueI18n from "vue-i18n";

import en from "./en";
import zh from "./zh";
// 导入饿了么UI的语言库
import enLocale from "element-ui/lib/locale/lang/en";
import zhLocale from "element-ui/lib/locale/lang/zh-CN";
Vue.use(VueI18n);
// 创建翻译规则
let messages = {
  en: {
    test: "test",
    home: {
      workCalerdar: "work-Calerdar",
      morning: "Good Morning"
    },
    departments: {
      operation: "operation"
    },
    ...enLocale,
    ...en
  },
  zh: {
    test: "测试",
    // 分模块来翻译
    home: {
      workCalerdar: "工作日历",
      morning: "早上好"
    },
    departments: {
      operation: "操作"
    },
    ...zhLocale,
    ...zh
  },
  ja: {
    test: "テスト",
    home: {
      workCalerdar: "作業カレンダー",
      morning: "おはようございます"
    },
    departments: {
      operation: "操作"
    }
  }
};

import Cookies from "js-cookie";
// 实例化一个i18n对象
let i18n = new VueI18n({
  // 默认用什么环境
  locale: Cookies.get("lang") || "zh",
  // 挂载翻译规则
  messages
});

export default i18n;
